package com.renyr.utils;

import java.io.Closeable;
import java.io.IOException;
import java.util.Random;
import java.util.UUID;

public class Common {

    /**
     * 生成uuid
     * @return string类型uuid
     */
    public String getUUID() {
        return UUID.randomUUID().toString().replace("-","");
    }

	/**
	 * 生成文件名称
	 * @return 文件名
	 */
	public String createImgName() {
		return getUUID() +"-"+ new TimeUtil().getNowMillisecond();
	}
	
	/**
	 * 关流
	 * @param ts 要关闭的流
	 */
    @SafeVarargs
	public static <T extends Closeable> void closeStream(T... ts) {
		if (null != ts) {
		    for (T t : ts){
		        if (t != null) {
                    try {
                        t.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
		}
	}
	
}
